﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Shop.Business.Domain.Orders.Logic
{
    public class RangeRestriction : IRestriction
    {
        private IComparable maxinmum;
        private IComparable minimum;
        private string maxinmumMessage;
        private string minimumMessage;

        // TODO use it
        private bool includeMinimumBoundary;
        private bool includeMaximumBoundary;

        public RangeRestriction(IComparable minimum, IComparable maxinmum)
        {
            this.maxinmum = maxinmum;
            this.minimum = minimum;

            if (maxinmum != null && minimum != null)
            {
                if (minimum.CompareTo(maxinmum) > 0)
                    throw new ArgumentException("minimum value(" + minimum + ") more then maximum (" + maxinmum + ")");
            }
        }

        public string MaxinmumMessage
        {
            get { return maxinmumMessage; }
            set { maxinmumMessage = value; }
        }

        public string MinimumMessage
        {
            get { return minimumMessage; }
            set { minimumMessage = value; }
        }

        /// <summary>
        /// null if was not set
        /// </summary>
        public IComparable Maxinmum
        {
            get { return maxinmum; }
        }

        /// <summary>
        /// null if was not set
        /// </summary>
        public IComparable Minimum
        {
            get { return minimum; }
        }

        public void Accept(IRestrictionVisitor visitor)
        {
            visitor.Accept(this);
        }
    }
}
